package inetAddress;

import java.net.InetAddress;
import java.net.UnknownHostException;

public class InetAddressDemo {
    public static void main(String[] args) throws UnknownHostException {
        InetAddress address = InetAddress.getByName("LAPTOP-968UOOOU");

        String hostAddress = address.getHostAddress();
        System.out.println("本机IP地址：" + hostAddress);

        String hostName = address.getHostName();
        System.out.println("本机名称：" + hostName);
    }
}
